//
//  VideoPlayViewController.m
//  SinaWebo
//
//  Created by 王方伟 on 2016/12/20.
//  Copyright © 2016年 亦心. All rights reserved.
//

#import "VideoPlayViewController.h"
#import <IJKMediaFramework/IJKMediaFramework.h>

@interface VideoPlayViewController ()
@property (strong, nonatomic) IJKFFMoviePlayerController *moviePlayer;
@end

@implementation VideoPlayViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"秒拍";
    IJKFFOptions *options = [IJKFFOptions optionsByDefault];
    [options setPlayerOptionIntValue:1  forKey:@"videotoolbox"];
    
    // 帧速率(fps) （可以改，确认非标准桢率会导致音画不同步，所以只能设定为15或者29.97）
    [options setPlayerOptionIntValue:29.97 forKey:@"r"];
    // -vol——设置音量大小，256为标准音量。（要设置成两倍音量时则输入512，依此类推
    [options setPlayerOptionIntValue:512 forKey:@"vol"];
    _moviePlayer = [[IJKFFMoviePlayerController alloc] initWithContentURLString:self.params[@"params"] withOptions:options];
    _moviePlayer.view.frame = self.view.bounds;
    [self.view addSubview:_moviePlayer.view];
    // 填充fill
    _moviePlayer.scalingMode = IJKMPMovieScalingModeAspectFill;
    // 设置自动播放(必须设置为NO, 防止自动播放, 才能更好的控制直播的状态)
    _moviePlayer.shouldAutoplay = YES;
    // 默认不显示
    _moviePlayer.shouldShowHudView = YES;
    
    [_moviePlayer prepareToPlay];
    [_moviePlayer play];
}

- (void)dealloc{
    [_moviePlayer stop];
}



@end
